Comment=require('../models/comment.js');
function CommentController(url){

}
CommentController.comment=function(req,res){
    res.render('comment', {
        title: '登录',
        user: req.session.user,
        success: req.flash('success').toString(),
        error: req.flash('error').toString()
    });
};
CommentController.post_comment=function(req,res){
    var title=req.body.title;
    var content=req.body.content;
    if(content==''){
        req.flash('error', '内容不能为空');
        return res.redirect('/comment');
    }
    var new_comment=new Comment({
        title:title,
        content:content
    })
    new_comment.save(function(err,comment){
        if (err) {
            req.flash('error', err);
            return res.redirect('/comment');
        }
        res.redirect('/comment');
    })
}
module.exports=CommentController;